﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<BA2009.Web.Controllers.BannerFormViewModel>" %>

<%@ Import Namespace="MvcContrib.UI.Grid" %>
<%@ Import Namespace="MvcContrib.UI.Grid.ActionSyntax" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Thay đổi Banner
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<script type="text/javascript" src="../../media/js/jTable-Customize.js"></script>
        <script type="text/javascript">
            
            var oTable;
            var oTablePosition;
            $(document).ready(function() {


            oTable = customTable("#search_datatable", "#chkResourceID_");
            oTablePosition = customTable("#search_datatable_position", "#chkPositionID_");
                setEditSelected("chkPositionID_");
                setEditSelected("chkResourceID_");
            }
        );
        
        
       
          
        
        
    </script>
    
        <link href="../../media/css/jtable.css" rel="stylesheet" type="text/css" />
        
          <h2>Thay đổi Banner</h2>

    <%= Html.ValidationSummary("Edit was unsuccessful. Please correct the errors and try again.") %>

    <% using (Html.BeginForm("Edit", "Banners", FormMethod.Post, new { id="mainform"})) {%>

        <fieldset>
            <legend>Fields</legend>
            
            <p>
                <%= Html.Hidden("BannerID", Model.Banner.BannerID) %>
            </p>
            
            <p>
                <label for="Code">Code:</label>
                <%= Html.TextBox("Code", Model.Banner.Code) %>
                <%= Html.ValidationMessage("Code", "*") %>
            </p>
          
            <p>
                <label for="BannerName">BannerName:</label>
                <%= Html.TextBox("BannerName", Model.Banner.BannerName) %>
                <%= Html.ValidationMessage("BannerName", "*") %>
            </p>
            
            <p>
                <label for="BannerTypeID">Loại Banner:</label>
                <%= Html.DropDownList("BannerTypeID", Model.BannerTypes)%>
            </p>
            
            <p>
            <div class="tablewidth">
             <fieldset>
                <legend>Tài nguyên</legend>
                
                <div id="search_container">
    <% Html.Grid(Model.Resources).Columns(column =>
           {
               column.For(c => c.ResourceID).Attributes(item => new MvcContrib.Hash(Checked=> item,id=>"resourceId")).Named("Chọn").Action(resource =>
                       {%>
                       <td>
                     
                            <input type="checkbox" <%= Model.Banner.Resources.Contains(resource.ResourceID)?"checked":"" %>  id="chkResourceID_<%= resource.ResourceID%>" name="chkResourceID_<%= resource.ResourceID%>" />
                           
                       </td>
                       <%
        });
               column.For(c => c.ResourceID).Named("ID");
               column.For(c => c.Code).Named("Mã");
               column.For(c => c.FileName).Named("Tên file");
               column.For(c => c.Description).Named("Miêu tả");
               
           })
           .Attributes(id => "search_datatable")
           .Render();
                     
            %>
    </div>
    
             </fieldset>
            </div>
            </p>
            
            <p>
                  <div class="tablewidth">
             <fieldset>
                <legend>Vị trí hiển thị</legend>
                
                     <div id="search_container_position">
    <% Html.Grid(Model.Positions).Columns(column =>
           {
               column.For(c =>  c.BannerPositionID).Attributes(id=>"resourceId").Named("Chọn").Action(position =>
                       {%>
                       <td>
                     
                            <input type="checkbox" <%= Model.Banner.BannerPositions.Contains(position.BannerPositionID)?"checked":"" %>   id="chkPositionID_<%=position.BannerPositionID %>" name="chkPositionID_<%= position.BannerPositionID%>" />
                           
                       </td>
                       <%
        });
               column.For(p => p.BannerPositionID).Named("ID");
               column.For(p => p.Code).Named("Mã");
               column.For(p => p.BannerPositionName).Named("Tên vị trí");
               
               
               
           })
           .Attributes(id => "search_datatable_position")
           .Render();
                     
            %>
    </div>

             </fieldset>
             
            </div>
            </p>
        
            <p>
                <input type="submit" value="Save" />
            </p>
        </fieldset>

    <% } %>

    <div>
        <%=Html.ActionLink("Back to List", "Index") %>
    </div>

</asp:Content>

